﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class temperature_outside : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String sResult = "0";
        String sResultValue = "err";
        String sAction = Request.QueryString["act"];

        if (sAction != null && sAction.Length > 0)
        {
            if (sAction == "get")
            {
                sResult = "1";
                sResultValue = Convert.ToString(StaticModel.GetTempOutside());
            }
            else if (sAction == "set")
            {
                String sReqValue = Request.QueryString["value"];
                if (sReqValue != null && sReqValue.Length > 0)
                {
                    //if () need to fix when value is not double
                    {
                        try 
                        { 
                            StaticModel.SetTempOutside(Convert.ToDouble(sReqValue));
                            sResultValue = Convert.ToString(StaticModel.GetTempOutside());
                            sResult = "1";
                        }
                        catch
                        {
                            sResult = "0";
                            sResultValue = "err1";
                            Console.WriteLine( e.ToString());
                        }
                        
                    }
                }
            }
        }

        Response.Write(sResult + "," + sResultValue);

    }
}